<!DOCTYPE html>
<html>
<head>
	<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
	<title>注册 - UG彩</title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<link rel="icon" href="favicon.ico" />
	<script type="text/javascript" src="login/js/jquery-1.11.3.min.js"></script>
	<script src="../public/all/js/jquery.cookie.js"></script>
	<script type="text/javascript" src="login/js/ug9.min.js"></script>

    <!-- debug only -->
    <script type="text/javascript" src="login/js/layer.js"></script>
    <script type="text/javascript" src="login/js/script.js"></script>
    <script src="../public/all/js/context.js"></script>
    <script src="../public/all/js/util.js"></script>
    <script src="../public/all/js/cmd.js"></script>
    <script src="../public/all/js/classify.js"></script>
	<!-- debug only end -->
		
	<link media="all" href="login/css/register.css" type="text/css" rel="stylesheet">
</head>
<body style="background: white none repeat scroll 0% 0%;">
	<div class="header">
		<div class="logo">
			<img src="login/images/logo.png">
		</div>
	</div>
	<div class="reg_info">
		<div class="top">
			<i></i>
			<span>请在以下填写您的注册信息</span>
		</div>
		<form id="main" method="post" name="main" action="#">
			<ul class="reg_te">
				<fieldset>
					<table>
						<tbody>
							<tr>
								<th>上级代理：</th>
								<td class="input"><input size="40" id="reg_referee" maxlength="15" class="validate[required,custom[onlyLetterNumber],minSize[6],maxSize[15]] inp-txt" value="" type="text"></td>
								<td class="clue">如果没有可不填</td>
							</tr>
							<tr>
								<th>会员账号：</th>
								<td class="input"><input size="40" id="reg_username" maxlength="15" class="validate[required,custom[onlyLetterNumber],minSize[6],maxSize[15]] inp-txt" value="" type="text"></td>
								<td class="clue">账号规则：账号必须为6-15为数字和字母组合</td>
							</tr>
							<tr>
								<th>登陆密码：</th>
								<td class="input"><input id="reg_password" maxlength="20" size="40" class="validate[required,minSize[6],maxSize[15]] inp-txt" type="password"></td>
								<td class="clue">密码规则：密码长度要有6-20个字符，以及必须含有数字和字母组合</td>
							</tr>
							<tr>
								<th>确认密码：</th>
								<td class="input"><input id="reg_password1" maxlength="20" size="40" class="validate[required,equals[reg_password]] inp-txt" type="password"></td>
								<td class="clue">确定密码</td>
							</tr>
							<tr>
								<th>提款密码：</th>
								<td class="input"><input id="reg_take_password" maxlength="4" size="40" class="validate[required,minSize[6],maxSize[15]] inp-txt" type="password"></td>
								<td class="clue">密码规则：4位数字</td>
							</tr>
							<tr>
								<th>真实姓名：</th>
								<td class="input"><input id="reg_name" size="40" maxlength="10" class="validate[required] inp-txt" value=""></td>
								<td class="clue">姓名必须与你用于提款的银行户口名字一致，否则无法提款</td>
							</tr>
							<tr>
								<th>电子邮箱：</th>
								<td class="input"><input id="reg_email" size="40" maxlength="30" class="validate[required,custom[email],minSize[4]] inp-txt" value="" type="text"></td>
								<td class="clue">email格式：888888@qq.com</td>
							</tr>
						</tbody>
					</table>
				</fieldset>
			</ul>

			<div>
				<div id="register-button">
					确认注册
				</div>
				<div class="login-content">
						如果您已有账号，可点击
						<a href="#" class="click_to_login">登录</a> 
						进入
				</div>
			</div>
		</form>
	</div>
</body>
</html>

<script>
	$(".click_to_login").click(function() {
		Util.jumpUrl({
			file: "index.html"
		});
	});

	// LOGO
    Classify.queryExt("settings", "logo-big", false, "", function(v) {
        if (v) {
			var url = context.config.url.replace(":9090", "");
			if (urlInfo.params.try == 1) url = context.config.tryUrl.replace(":9090", "");
            $(".headerc img").attr("src", url + v);
        }
    });

	// 填入代理
	if (urlInfo.params.referee) {
        $("#reg_referee").val(urlInfo.params.referee);
	}
	
	$("#register-button").click(function() {
		// 提交注册
        var referee = $("#reg_referee").val().trim();
        var account = $("#reg_username").val().trim();
        var p1 = $("#reg_password").val().trim();
        var p2 = $("#reg_password1").val().trim();
        var name = $("#reg_name").val().trim();
        var p3 = $("#reg_take_password").val().trim();
        var email = $("#reg_email").val().trim();

        if (account == "") {
            alert("账号名称不能为空");
            $("#reg_username").focus();
            return false;
        }
        if (! /^[0-9a-zA-Z]{6,15}$/.test(account)) {
            alert("用户名6~15位数字或字母");
            $("#reg_username").focus();
            return false;
        }
        if (!p1) {
            alert("密码不能为空");
            $("#reg_password").focus();
            return false;
        }
        if (p1.length > 20) {
            alert("密码不能大于20个字符。");
            $("#reg_password").focus();
            return false;
        }
        if (p1.length < 6) {
            alert("密码不能小于6个字符。");
            $("#reg_password").focus();
            return false;
        }
        if (p1 != p2) {
            alert("输入的密码不一致，请重新输入。");
            $("#reg_password1").focus();
            return false;
		}
		
		if (!/^[0-9]{4}$/.test(p3)) {
			alert("取款密码格式不对。");
            $("#reg_take_password").focus();
            return false;
		}

        if (!name) {
            aler2("真实姓名不能为空");
            $("#reg_name").focus();
            return false;
        }
        if (!/^[\u4E00-\u9FA5]{2,8}$/.test(name)) {
            alert("请输入正确的真实姓名");
            $("#reg_name").focus();
            return false;
        }
        if (!email) {
            alert("电子邮箱不能为空");
            $("#reg_email").focus();
            return false;
        }
        if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email)) {
            alert("您的电子邮件格式不正确");
            $("#reg_email").focus();
            return false;
		}

        urlInfo.params.try = 0;
        CMD.register(account, p1, name, "", referee, "pc", function(r) {
            CMD.modify_user_info(null, {
                tpassword: p3,
                email2: email,
            }, function() {
                Util.jumpUrl({
                    file: "agreement.html"
                });
            });
        }, function(r) {
            if (r) {
				r = r.replace("手机号", "账号");
				alert("注册失败，原因：" + r);
			}
            else alert("注册失败！");
        })
		return false;
	})
</script>
